package com.kwlt.smc.dao;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.kwlt.smc.entity.Channel;
import com.kwlt.smc.util.ConUtils;



public class ChannelDao{
	
	public Channel findChannelByNumbers(String numbers){
		Channel channel = new Channel();
		String sql = "select c.* from channel c where c.status!='X' and c.numbers = '"+numbers+"'";
		Connection conn = null;
		Statement st = null;
		try {
			conn = DbcpPoolManager.getConnection();
			st = conn.createStatement();
			ResultSet rs = st.executeQuery(sql);
			while(rs.next()){
				channel.setNumbers(rs.getString("NUMBERS"));
				channel.setAccessNumber(rs.getString("ACCESS_NUMBER"));
				channel.setOperators(rs.getString("OPERATORS"));
				channel.setMtDir(rs.getString("MT_DIR"));
				channel.setRptDir(rs.getString("RPT_DIR"));
				channel.setMoDir(rs.getString("MO_DIR"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			if(st!=null){
				ConUtils.closeStatement(st);
			}
			if(conn!=null){
				ConUtils.closeConnection(conn);
			}
		}
		return channel;
	}
}
